package lab02.test13;

public class Gymnastics extends ComputerAverage {
    //计算选手的平均成绩的方法是去掉一个最低分，
    // 去掉一个最高分，然后求平均分

    double chinese;
    double math;
    double english;

    double average(){
        double []a = {chinese,math,english};
        double min;
        double max;
        min = max = a[0];

        int y1 = 0;
        int y2 = 0;
        for (int i = 0;i <a.length;i++){
            if(a[i] > max){
                max = a[i];
                y1 = i;
            }else if (a[i] < min){
                min = a[i];
                y2 = i;
            }
        }

        a[y1] = 0;
        a[y2] = 0;

        double sum = 0;
        for (int i = 0;i <a.length;i++){
            sum = sum + a[i];
        }

        double average;
        average = sum / a.length;
        return average;
    }
}
